From: Dan Nicholson Date: Sat, 30 Jul 2016 15:14:17 +0000 (-0500) Subject: deltas: Allow processing of empty delta parts X-Git-Tag: archive/raspbian/2022.1-3+rpi1~1^2~4^2~49^2~42 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/www.github.com/%22bookmarks:///%22http:/www.example.com/cgi/%22https:/www.github.com/%22bookmarks:/?a=commitdiff_plain;h=512090785e039e560f5e0df9b1e1db004298eeb6;p=ostree.git deltas: Allow processing of empty delta parts If a static delta is generated between 2 commits with the same content, then the delta will contain 1 part with no checksums. While useless, this is a valid delta that shouldn't raise an assertion. If the delta part has no checksums, then there are no objects to recreate and the processing can be skipped. Closes: #420 Approved by: cgwalters --- diff --git a/src/libostree/ostree-repo-static-delta-core.c b/src/libostree/ostree-repo-static-delta-core.c index 68c45055..46fa5f86 100644 --- a/src/libostree/ostree-repo-static-delta-core.c +++ b/src/libostree/ostree-repo-static-delta-core.c @@ -42,8 +42,7 @@ _ostree_static_delta_parse_checksum_array (GVariant *array, n_checksums = n / OSTREE_STATIC_DELTA_OBJTYPE_CSUM_LEN; - if (G_UNLIKELY(n == 0 || - n > (G_MAXUINT32/OSTREE_STATIC_DELTA_OBJTYPE_CSUM_LEN) || + if (G_UNLIKELY(n > (G_MAXUINT32/OSTREE_STATIC_DELTA_OBJTYPE_CSUM_LEN) || (n_checksums * OSTREE_STATIC_DELTA_OBJTYPE_CSUM_LEN) != n)) { g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, diff --git a/src/libostree/ostree-repo-static-delta-processing.c b/src/libostree/ostree-repo-static-delta-processing.c index f78b7ab7..304d7b4a 100644 --- a/src/libostree/ostree-repo-static-delta-processing.c +++ b/src/libostree/ostree-repo-static-delta-processing.c @@ -210,8 +210,14 @@ _ostree_static_delta_part_execute (OstreeRepo *repo, error)) goto out; + /* Skip processing for empty delta part */ + if (state->n_checksums == 0) + { + ret = TRUE; + goto out; + } + state->checksums = checksums_data; - g_assert (state->n_checksums > 0); g_variant_get (part, "(@a(uuu)@aa(ayay)@ay@ay)", &mode_dict,